<template>
    <div style="padding:20px;">
        <el-table :data="anchors">
            <el-table-column fixed prop="id" label="用户ID" width="150">
            </el-table-column>
            <el-table-column prop="name" label="主播名" width="120">
            </el-table-column>
            <el-table-column prop="phone" label="手机" width="120">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                    size="mini"
                    @click="pass(scope.$index, scope.row)">通过</el-button>
                    <el-button
                    size="mini"
                    type="danger"
                    @click="reject(scope.$index, scope.row)">驳回</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    name: 'checkAnchor',
    components: {},
    data() {
        return {
            anchors: [],
            pageInfo: {}
        };
    },
    methods: {
        queryAll() {
            let params = {
                pageNum: 1,
                pageSize: 10
            };
            this.$ajax
                .get('/user/checkAnchor', {
                    params
                })
                .then(res => {
                    const { list, pageNum, pageSize, pages, total } = res.data;
                    this.anchors = list;
                    this.pageInfo = {
                        pageNum,
                        pageSize,
                        pages,
                        total
                    };
                });
        },
        pass(index, rows) {
            this.$ajax
                .post('/user/check/pass', {
                    id: rows.id
                })
                .then(res => {
                    if (res.code === 1) {
                        this.$message({
                            message: '审核通过',
                            type: 'success'
                        });
                        this.queryAll();
                    } else {
                        this.$message.error('审核失败,请重新审核!');
                    }
                });
        },
        reject(index, rows) {
            this.$ajax
                .post('/user/check/reject', {
                    id: rows.id
                })
                .then(res => {
                    if (res.code === 1) {
                        this.$message({
                            message: '驳回成功',
                            type: 'success'
                        });
                        this.queryAll();
                    } else {
                        this.$message.error('驳回失败,请重新审核!');
                    }
                });
        }
    },
    mounted() {
        this.queryAll();
    }
};
</script>

